#@layout()

#define script()
<script>

    function doDel(id) {
        if (confirm("确定要删除该优惠码吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/finance/coupon/doCodeDel/" + id);
        }
    }

</script>
#end

#define content()

    <section class="content-header">
        <h1>
            优惠券领取列表
            <small>Coupon User List</small>
        </h1>
    </section>

    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-header with-border">

                        <div class="row admin-search-panel">
                            <div class="col-12">
                                <a href="#(CPATH)/admin/finance/coupon/takeEdit?cid=#(coupon.id)" class="btn btn-primary ">
                                    <i class="fas fa-plus"></i> 新分配
                                </a>
                                <button type="submit" id="batchDel" class="btn btn-default checkAction"> 批量删除</button>
                            </div>
                        </div>

                    </div>
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 10px">
                                    <input class="tableCheckAll" id="checkall" type="checkbox"/>

                                <th style="">优惠码</th>
                                <th style="width: 25%">优惠券名称</th>
                                <th style="width: 15%">领取用户</th>
                                <th style="width: 15%">领取时间</th>
                                <th style="width: 10%">状态</th>
                            </tr>
                            #for(code : page.list ??)
                            <tr>
                                <td><input name="tableItem" type="checkbox" value="#(code.id ??)" />
                                </td>
                                <td>
                                    <strong>
                                        #(code.code ??)
                                    </strong>
                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/finance/coupon/takeEdit/#(code.id)?cid=#(code.coupon_id)">编辑</a> |
                                            <a href="#(CPATH)/admin/finance/coupon/useds/?codeid=#(code.id)">使用记录</a> |
                                            <a href="javascript:;" class="red-action" onclick="doDel('#(code.id)')">删除</a>
                                        </div>
                                    </div>
                                </td>
                                <td>#(code.title ??)</td>
                                <td>
                                    <a href="#(CPATH)/admin/user/detail/#(code.user.id ??)">#(code.user.nickname ??)</a>
                                </td>
                                <td>
                                    #date(code.valid_time ??)
                                </td>
                                <td>#(code.statusStr ??)</td>
                            </tr>
                            #else
                            <tr class="nodata"><td colspan="999">暂无数据</td> </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="row">

                                    <div class="form-group">
                                        <div class="form-check">
                                            <input class="form-check-input tableCheckAll" id="checkall" type="checkbox" >
                                            <label class="form-check-label" for="checkall">全选</label>
                                        </div>
                                    </div>
                                    <div class="form-group col-lg-3">
                                        <select class="form-control" name="action">
                                            <option value="">请选择...</option>
                                            <option value="doDelByIds" open-type="del-confirm">
                                                批量删除
                                            </option>
                                        </select>
                                    </div>

                                    <div class="form-group col-lg-3">
                                        <button type="button" class="btn btn-outline-primary batchExec">批量操作</button>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div>
    </section>
#end
